﻿using Abp.Domain.Entities;
using Abp.Domain.Entities.Auditing;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GN.Pay.Core.Entities
{
    /// <summary>
    /// 商户应用通道
    /// </summary>
    [Table("Merchant_AppChannel")]
    [Serializable]
    public class MerchantAppChannel : Entity<long>, IHasCreationTime, IHasModificationTime
    {
        /// <summary>
        /// 应用Id
        /// </summary>
        [Required]
        [StringLength(maximumLength: 32)]
        public string AppId { get; set; }

        /// <summary>
        /// 应用通道Id
        /// </summary>
        [Required]
        [StringLength(maximumLength: 32)]
        public string ChannelId { get; set; }

        /// <summary>
        /// 应用通道名称
        /// </summary>
        [Required]
        [StringLength(maximumLength: 50)]
        public string ChannelName { get; set; }

        /// <summary>
        /// 通道类型
        /// </summary>
        public int ChannelType { get; set; }

        /// <summary>
        /// 配置数据
        /// </summary>
        [Required]
        public string ConfigureData { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        public virtual DateTime CreationTime { get; set; }

        /// <summary>
        /// 最后修改时间
        /// </summary>
        public virtual DateTime? LastModificationTime { get; set; }

        /// <summary>
        /// 状态(1=正常)
        /// </summary>
        public int State { get; set; }

        /// <summary>
        /// 缓存键
        /// </summary>
        /// <returns></returns>
        public string CacheKey()
        {
            return CacheKey(AppId, ChannelId);
        }

        /// <summary>
        /// 缓存键
        /// </summary>
        /// <param name="appId"></param>
        /// <param name="channelId"></param>
        /// <returns></returns>
        public static string CacheKey(string appId, string channelId)
        {
            return string.Format("{0}@{1}", appId, channelId);
        }
    }
}
